package com.dick.base.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dick.base.dto.TipDetail;
import com.dick.base.model.BaseNotify;
import com.dick.base.model.BusinessOrder;
import com.dick.base.service.NotifyService;
import com.dick.base.session.util.SessionUtil;
import com.dick.base.util.BaseResult;
import com.dick.base.util.PageInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 通知api
 */
@RestController
@RequestMapping("api/notify")
public class NotifyApi {
    private static final String TAG = "通知";
    @Autowired
    private NotifyService notifyService;

    @ApiOperation(value = "获取通知列表", tags = TAG)
    @GetMapping("notify-list")
    public BaseResult<Page<BaseNotify>> notifyList(PageInfo pageInfo) {
        return BaseResult.of(notifyService.notifyList(SessionUtil.currentUser().getId(),pageInfo));
    }

    @ApiOperation(value = "设置通知已读", tags = TAG)
    @GetMapping("notify-read")
    public BaseResult<Void> notifyRead(@RequestBody List<Long> ids) {
        notifyService.setNotifyRead(ids);
        return BaseResult.voidResult();
    }

    @ApiOperation(value = "清空通知", tags = TAG)
    @GetMapping("notify-empty")
    public BaseResult<Void> notifyEmpty() {
        notifyService.deleteUserNotify(SessionUtil.currentUser().getId());
        return BaseResult.voidResult();
    }
}
